package models

import (
	"github.com/goccy/go-json"
	"leading/models/ctype"
)

type UserModel struct {
	MODEL
	Username   string          `json:"username" form:"username" binding:"required,min=5,max=20" gorm:"size:30;NOT NULL;comment:昵称;"`
	Nickname   string          `json:"nickname" form:"nickname" binding:"required,max=20" gorm:"size:30l;NOT NULL;comment:昵称"`
	Email      string          `json:"email"  form:"email" gorm:"NOT NULL;size:160;comment:邮箱"`
	Sex        ctype.SexStatus `json:"sex"  form:"sex" gorm:"type:smallint(6);default: 1;comment:性别"`
	Desc       string          `json:"desc" form:"desc" gorm:"type:longText;comment:个性签名"`
	TotalSize  uint            `json:"total_size" form:"total_size" gorm:"comment:网盘总大小，单位字节, 默认100M;default:104857600"`
	UseSize    uint            `json:"use_size" form:"use_size" gorm:"comment:网盘已使用，单位字节;default:0"`
	Password   string          `json:"password" form:"password" binding:"required"`
	RePassword string          `json:"re_password,omitempty" form:"re_password" binding:"required" gorm:"-"`
}

type ResUser struct {
	Username  string          `json:"username"`
	Nickname  string          `json:"nickname"`
	Email     string          `json:"email"`
	Sex       ctype.SexStatus `json:"sex"`
	Desc      string          `json:"desc"`
	TotalSize uint            `json:"total_size"`
	UseSize   uint            `json:"use_size"`
}

type RegisterRes struct {
	ResUser
	Token string `json:"token"`
}

func (info UserModel) MarshalBinary() (data []byte, err error) {
	return json.Marshal(info)
}
